package com.yochi.pictureseditor.activities;

import com.yochi.pictureseditor.R;
import com.yochi.pictureseditor.tools.SettingsManager;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

public class SettingsChooser extends Activity{
	
	public static final String TAG = "SettingsChooser";
	
	private TextView textViewHead;
	private CheckBox cbZoomEnabled;
	private CheckBox cbLabelEnabled;
	
	private Button okButton;
	private Button cancelButton;
	
    @Override
	public void onCreate(Bundle savedInstanceState) {
		Log.d(TAG,"::onCreate /ApplicationParametersChooser.java/");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
     
        // get views
        textViewHead = (TextView) findViewById(R.id.textview_color);
        cbZoomEnabled = (CheckBox) findViewById(R.id.checkBox_zoomEnabled);
        cbLabelEnabled = (CheckBox) findViewById(R.id.checkBox_labelEnabled);
    	okButton = (Button) findViewById(R.id.button_color_ok);
    	cancelButton = (Button) findViewById(R.id.button_color_cancel);
        
    	// customize views
    	textViewHead.setText(R.string.activity_settings);
    	cbZoomEnabled.setChecked(SettingsManager.isZoomEnabled());
    	cbLabelEnabled.setChecked(SettingsManager.isLabelEnabled());
    	
        // validate button listener
        okButton.setOnClickListener(new Button.OnClickListener() {  
	        public void onClick(View v) {
	        	SettingsManager.setZoomEnabled(SettingsChooser.this, cbZoomEnabled.isChecked());
	        	SettingsManager.setLabelEnabled(SettingsChooser.this, cbLabelEnabled.isChecked());
	        	setResult(RESULT_OK);
	        	onDestroy();
	    }	});
        
        // cancel button listener
        cancelButton.setOnClickListener(new Button.OnClickListener() {  
	        public void onClick(View v) {
	        	setResult(RESULT_CANCELED);
	        	onDestroy();
	    }	});
	}
	
    @Override
    public void onDestroy() {
    	super.onDestroy();
    	finish();
    }
}
